package com.assignwork.service.impl;

import com.assignwork.dto.SafeLibrarySearchDTO;
import com.assignwork.dto.SafeLibrarySubmitDTO;
import com.assignwork.entity.SafeLibrary;
import com.assignwork.mapper.SafeLibraryMapper;
import com.assignwork.service.ISafeLibraryService;
import com.assignwork.vo.SafeLibraryListVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SafeLibraryServiceImpl
 * @Description 安全知识库接口实现
 * @Author dujianyu
 * @Date 2023/12/24 16:14
 */
@Service
public class SafeLibraryServiceImpl extends BaseServiceImpl<SafeLibraryMapper, SafeLibrary> implements ISafeLibraryService {
    @Override
    public IPage<SafeLibraryListVO> selectSafeLibraryPage(SafeLibrarySearchDTO dto, IPage<SafeLibraryListVO> page) {
        List<SafeLibraryListVO> data = baseMapper.selectSafeLibraryList(dto, page);
        return page.setRecords(data);
    }

    @Override
    public List<SafeLibraryListVO> selectSafeLibraryList(SafeLibrarySearchDTO dto) {
        return baseMapper.selectSafeLibraryList(dto, null);
    }

    @Override
    public boolean submitSafeLibrary(SafeLibrarySubmitDTO dto) {
        SafeLibrary entity = BeanUtil.copy(dto, SafeLibrary.class);
        return super.saveOrUpdate(entity);
    }
}
